//
//  XMOrderResellDetailViewController.m
//  XMJJ_zml
//
//  Created by 丁浩 on 2025/6/25.
//

#import "XMOrderResellDetailViewController.h"
#import "XMOrderResellDetailView.h"
#import "XMNetwork+mine.h"
#import "XMNetwork+home.h"
#import "XMConfirmOrderViewController.h"
#import "XMPayViewController.h"

@interface XMOrderResellDetailViewController ()<XMOrderResellDetailViewDelegate>

@property (nonatomic, strong) XMOrderResellDetailView *orderResellDetailView;
@property (nonatomic, strong) XMOrderDetailModel *orderDetailModel;

@end

@implementation XMOrderResellDetailViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    [self creatUI];
}

- (void)creatUI {
    [self.view addSubview:self.orderResellDetailView];
    [self getOrderDetailInfo];
}

- (void)getOrderDetailInfo {
    XMWeakSelf;
    [_Network getOrderDetailWithOrderId:_orderId
                                success:^(id  _Nonnull responseObject) {
        XMOrderDetailModel *orderDetailModel = [XMOrderDetailModel yy_modelWithJSON:responseObject[@"data"]];
        weakSelf.orderDetailModel = orderDetailModel;
        [weakSelf.orderResellDetailView setContentWithOrderDetailModel:orderDetailModel];
    } failure:^(NSError * _Nonnull error) {
        
    }];
}

#pragma mark - Delegate
//删除结束订单
- (void)meetDeleteAction {
    XMWeakSelf;
    [_Network deleteMeetingWithServiceId:_orderId
                                 success:^(id  _Nonnull responseObject) {
        weakSelf.meetEditBlock ? weakSelf.meetEditBlock() : nil;
        [weakSelf.navigationController popViewControllerAnimated:YES];
    } failure:^(NSError * _Nonnull error) {
        
    }];
}

//重新下单
- (void)reputawayActionWithServiceId:(NSString *)serviceId {
    [_Network creatOrderWithServiceId:serviceId
                              success:^(id  _Nonnull responseObject) {
//        XMPayViewController *payVC = [[XMPayViewController alloc] init];
//    payVC.orderId = @"191";//[responseObject safeStringForKey:@"data"];
//    payVC.priceStr = @"200";
    } failure:^(NSError * _Nonnull error) {
        
    }];
//    XMWeakSelf;
//    [_Network meetingReputawayWithServiceId:serviceId
//                                    success:^(id  _Nonnull responseObject) {
//        weakSelf.meetEditBlock ? weakSelf.meetEditBlock() : nil;
//        [weakSelf.navigationController popViewControllerAnimated:YES];
//    } failure:^(NSError * _Nonnull error) {
//
//    }];
}

#pragma mark - Init
- (XMOrderResellDetailView *)orderResellDetailView {
    if (!_orderResellDetailView) {
        _orderResellDetailView = [[XMOrderResellDetailView alloc] initWithFrame:self.view.bounds meetingType:_meetTypeStr];
        _orderResellDetailView.delegate = self;
    }
    return _orderResellDetailView;
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
